<?php
namespace app\common\logic\ad\driver;


use app\common\logic\ad\Driver;
use think\Db;
use think\exception\ValidateException;

/**
 * Created by PhpStorm.
 * User: yangchunfu
 * Date: 2019/12/24
 * Time: 4:36 PM
 */

class Search extends Driver
{
    protected $options = [
    ];
    protected $rule = [1, 2, 3, 'other'];

    protected $htmlTpl = 'search.html';
    protected $ruleWhere = [
        'mark' => 'search'
    ];






    public function insertRule($ads_id = null)
    {
        return '';

    }


/**********************************接口部分*/

    /**
     * 获取广告 接口 api
     * @return array
     */
    public function select($where = []){

        //获取广告数据
        $ad = $this->adModel->where('id','IN',function($query) use($where) {
            $query->name('self_ad_rule')->where($this->getRule())->field('ad_ads_id');
        })->orderRaw('rand()')->limit(1)->where($where)->find();

        return $ad;
    }

}